/*
 * Copyright (C) 2007-2008  Hylke van der Schaaf
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, in version 3 of the License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package hextd.blackBox;

import hextd.core.Context;
import hextd.message.MessagePlayerForfeit;

/**
 *
 * @author hylke
 */
public class BBActionPlayerForfeit implements BBAction {

	private static final BlackBox.ActionType type = BlackBox.ActionType.PlayerForfeit;
	private int gameTime;
	private int player;

	/** Creates a new instance of BBActionUpgradeTower */
	public BBActionPlayerForfeit(int gameTime, int player) {
		this.gameTime = gameTime;
		this.player = player;
	}

	@Override
	public BlackBox.ActionType getType() {
		return BBActionPlayerForfeit.type;
	}

	@Override
	public int getGameTime() {
		return this.gameTime;
	}

	@Override
	public void execute(Context c) {
		//System.out.println("BBActionNewTower::execute: "+c.gameTime+" Upgrading Tower.");
		if (!c.getBlackBox().playerForfeit(gameTime, player)) {
			System.err.println("BBActionPlayerForfeit::execute: Sync error: Player forfeit failed!");
		}
	}

	@Override
	public String getString() {
		return MessagePlayerForfeit.formatMessage(gameTime, player);
	}
}
